/**
 * Title: BaseApplication.java
 * Description:
 * Copyright: Copyright (c) 2008
 * Company:深圳彩讯科技有限公司
 * Author 罗旭东 (hi@luoxudong.com)
 * Date 2014-1-9 下午9:46:15
 * Version 1.0
 */
package com.luoxudong.phonenumber.logic.common;

import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.view.WindowManager;

import com.luoxudong.phonenumber.logic.errorreport.AppUncaughtExceptionHandler;
import com.luoxudong.phonenumber.service.base.GlobleInfo;
import com.luoxudong.phonenumber.service.base.SingletonFactory;
import com.luoxudong.phonenumber.service.utils.EvtLog;
import com.luoxudong.phonenumber.service.utils.PackageUtil;

/** 
 * ClassName: BaseApplication
 * Description:TODO(这里用一句话描述这个类的作用)
 * Create by 罗旭东
 * Date 2014-1-9 下午9:46:15
 */
public class BaseApplication extends Application{
	private static final String TAG = "ThinkDriveApplication";
	public static Context CONTEXT = null;
	private static BaseApplication mInstance;

	public BaseApplication() {
		mInstance = this;
	}

	public static BaseApplication instance() {
		if (mInstance == null) {
			mInstance = new BaseApplication();
		}
		return mInstance;
	}
	@Override
	public void onCreate() {
		super.onCreate();
		CONTEXT = getApplicationContext();
		WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
		GlobleInfo.phoneModel = Build.MODEL;
		GlobleInfo.location =  PackageUtil.getPhoneLocation(this);
		GlobleInfo.screenScale = PackageUtil.getScreenScale(this);
		GlobleInfo.screenWidth = wm.getDefaultDisplay().getWidth();//屏幕宽度
		GlobleInfo.screenHeight = wm.getDefaultDisplay().getHeight();//屏幕高度
		//设置未捕获异常处理器
		Thread.setDefaultUncaughtExceptionHandler(SingletonFactory.getInstance(AppUncaughtExceptionHandler.class));
		
		EvtLog.i(TAG, "Application启动完成...");
	}
	
	@Override
	public void onTerminate() {//调用时机问题
		super.onTerminate();
	}
}
